package com.fcscs.cservice.ws;

import java.io.IOException;

import sun.misc.BASE64Decoder;
import sun.misc.BASE64Encoder;

public class WebServiceUtils {

	public static byte[] convertToByteArray(String base64Str) {

		if (base64Str == null || "".equals(base64Str.trim())) {
			return null;
		}

		BASE64Decoder decoder = new BASE64Decoder();
		byte[] bloc = null;
		try {
			bloc = decoder.decodeBuffer(base64Str);
		} catch (IOException e) {
			e.printStackTrace();
		}
		return bloc;
	}

	public static String convertToString(byte[] file) {

		if (file == null) {
			return null;
		}

		BASE64Encoder encoder = new BASE64Encoder();
		return encoder.encode(file);
	}

}
